package com.example.fengyungo.dao;

import com.example.fengyungo.domain.pojo.DriverVerify;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DriverVerifyDao {

    /**
     * 添加司机证明材料信息
     * @param driverVerify 司机证明材料信息
     * @return 添加成功>0
     */
    @Insert("insert into driver_verify " +
            "(driverId, name, idCard, idCardPeople, idCardEmblem, idCardWithPeople, driverCard, time, status) " +
            "VALUES " +
            "(#{driverId}, #{name}, #{idCard}, #{idCardPeople}, #{idCardEmblem}, #{idCardWithPeople}, #{driverCard}, #{time}, #{status})")
    Integer addDriverVerify(DriverVerify driverVerify);

    /**
     * 获取所有司机证明材料信息，按时间先后排序
     * @return 所有司机证明材料信息
     */
    @Select("select * from driver_verify order by time")
    List<DriverVerify> getAllDriverVerify();

    /**
     * 获取所有未处理的司机证明材料信息，按时间先后排序
     * @return 所有司机证明材料信息
     */
    @Select("select * from driver_verify where status = 0 order by time")
    List<DriverVerify> getAllDriverVerifyNotHandled();

    /**
     * 更新司机证明材料信息，通过司机id
     * @param driverVerify 司机证明材料信息
     * @return 更新成功>0
     */
    Integer updateDriverVerifyById(DriverVerify driverVerify);

    /**
     * 通过司机id获取司机姓名
     * @param driverId 司机id
     * @return 司机姓名
     */
    @Select("select name from driver_verify where driverId = #{driverId}")
    String getDriverNameById(String driverId);
}
